package com.zdb.demo.design.pattern.behavioral.strategy;

import java.util.HashMap;
import java.util.Map;

public class PromotionStrategyFactory {

    static private Map<String, PromotionStrategy> promotionStrategyMap = new HashMap<>();

    static {
        promotionStrategyMap.put(PromotionKey.MANJIAN, new ManjianPromotionStrategy());
        promotionStrategyMap.put(PromotionKey.LIJIAN, new LijianPromotionStrategy());
        promotionStrategyMap.put(PromotionKey.FANXIAN, new FanxianPromotionStrategy());
    }

    final static PromotionStrategy NON_PROMOTION = new NONPromotionStrategy();

    interface PromotionKey {
        String MANJIAN = "MANJIAN";
        String LIJIAN = "LIJIAN";
        String FANXIAN = "FANXIAN";
    }

    public static PromotionStrategy getPromotionStrategy(String promotionKey) {
        PromotionStrategy promotionStrategy = promotionStrategyMap.get(promotionKey);
        return promotionStrategy == null ? NON_PROMOTION : promotionStrategy;
    }
}
